package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbSeckillOrderMapper;
import com.dongdongshop.pojo.TbSeckillOrder;
import com.dongdongshop.service.SeckillOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description
 * @ClassName SeckillServiceImpl
 * @Author RC
 * @date 2020.12.30 16:21
 */
@Component
@Service
public class SeckillOrderServiceImpl implements SeckillOrderService {
    @Autowired
    private TbSeckillOrderMapper tbSeckillOrderMapper;

    @Transactional
    @Override
    public void createOrder(TbSeckillOrder seckillOrder) {
        tbSeckillOrderMapper.insertSelective(seckillOrder);
    }

    @Override
    public void updateStatusById(String trade_no, Long id) {
        TbSeckillOrder seckillOrder = tbSeckillOrderMapper.selectByPrimaryKey(id);
        seckillOrder.setTransactionId(trade_no);
        seckillOrder.setStatus("1");
        tbSeckillOrderMapper.updateByPrimaryKeySelective(seckillOrder);
    }
}
